package com.lzw.breezeNovel.webApp.mapper.comic;

import com.lzw.breezeNovel.model.entity.pojo.comic.Comic;
import com.lzw.breezeNovel.model.entity.pojo.comic.ComicCollection;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.mapper.comic
 * @date 2025/3/16
 * @description
 */
@Mapper
@SuppressWarnings("all")
public interface ComicCollectionMapper {

    /**
     * 根据用户ID和漫画ID查询收藏记录
     * @param id
     * @param comicId
     * @return
     */
    @Select("select count(*) from comic_collection where user_id=#{id} and comic_id=#{comicId}")
    Long selectCountByUserIdAndComicId(Long id, Integer comicId);

    /**
     * 添加收藏记录
     * @param comicCollection
     */
    @Insert("insert into comic_collection(user_id,comic_id,collect_time) values(#{userId},#{comicId},now())")
    void insert(ComicCollection comicCollection);

    /**
     * 删除收藏记录
     * @param id
     * @param comicId
     */
    @Delete("delete from comic_collection where user_id=#{id} and comic_id=#{comicId}")
    void deleteByUserIdAndComicId(Long id, Integer comicId);

    @Delete("delete from comic_collection where user_id=#{id} and comic_id=#{comicId}")
    void deleteByUserId(Long id,Integer comicId);

    /**
     * 根据用户ID查询收藏记录
     * @param id
     * @return
     */
    List<Comic> selectByUserId(@Param("id") Long id);
}
